package com.msos.service.sendMsgService;

import com.msos.dao.sendMsgDao.sendMsgDao;

import com.msos.model.customer.Customer;
import com.msos.utils.CommonsUtils;

import java.sql.SQLException;

public class sendMsgService {
    sendMsgDao sendMsgdao=new sendMsgDao();
    //1.判断该手机号用户是否存在
    //2.发送信息
    public Integer sendMsg(String acPhoNumber, String msg,String sePhoNumber) {
        Customer c= null;
        Integer r1=-1;
        try {
            c = sendMsgdao.getCustomerByPho(acPhoNumber);
            System.out.println("customer==x===="+c);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        if(c==null){
            return CommonsUtils.NOTHING;
        }

        try {
             r1 = sendMsgdao.sendMsg(acPhoNumber,msg,sePhoNumber);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return r1==CommonsUtils.SUCCESS?CommonsUtils.SUCCESS:CommonsUtils.FAIL;
    }
}
